#!/bin/bash

CONF=/etc/named/named.conf

if  [ "X$1" != "Xden" -a "X$1" != "Xphx" -a "X$1" != "Xlvs" -a "X$1" != "Xno" -o  $# -ne 1 ]; then
	echo -e "
		Usage: $(basename $0) den|phx|lvs|no
"
	exit 1
fi	

if [ "X$(uname -s)" == "XSunOS" ]; then
    GREP="/usr/xpg4/bin/grep"
    SED="/usr/xpg4/bin/sed"
else
    GREP="/bin/grep"
    SED="/bin/sed"
fi

notify=$1

case $notify in
"den" )
	$SED	\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NOTIFY_DEN//'		\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NOTIFY[[:space:]]//'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NO_NOTIFY[[:space:]]*$/s/^/\/\/ START_OF_NO_NOTIFY /'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NOTIFY_PHX[[:space:]]*$/s/^/\/\/ START_OF_NOTIFY_PHX/'	\
	$CONF
	;;

"lvs" )
	$SED	\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NOTIFY_LVS//'		\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NOTIFY[[:space:]]//'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NO_NOTIFY[[:space:]]*$/s/^/\/\/ START_OF_NO_NOTIFY /'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NOTIFY_LVS[[:space:]]*$/s/^/\/\/ START_OF_NOTIFY_LVS/'	\
	$CONF
	;;

"phx" )
	$SED	\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NOTIFY_PHX//'		\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NOTIFY[[:space:]]//'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NO_NOTIFY[[:space:]]*$/s/^/\/\/ START_OF_NO_NOTIFY /'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NOTIFY_DEN[[:space:]]*$/s/^/\/\/ START_OF_NOTIFY_DEN/'	\
	$CONF
	;;
"no" )
	$SED	\
		-e 's/^[[:space:]]*\/\/[[:space:]]*START_OF_NO_NOTIFY[[:space:]]*//'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NOTIFY_DEN[[:space:]]*$/s/^/\/\/ START_OF_NOTIFY_DEN/'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NOTIFY_PHX[[:space:]]*$/s/^/\/\/ START_OF_NOTIFY_PHX/'	\
		-e '/^[[:space:]]*[^//].*[[:space:]]*END_OF_NOTIFY[[:space:]]*$/s/^/\/\/ START_OF_NOTIFY /'		\
	$CONF
	;;

esac
